<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="__ROOT__/Public/Admin/css/shortcut icon" href="favicon.ico">
    <link href="__ROOT__/Public/Admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__ROOT__/Public/Admin/css/animate.css" rel="stylesheet">
    <link href="__ROOT__/Public/Admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__ROOT__/Public/Admin/js/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__ROOT__/Public/Admin/css/edit.css" rel="stylesheet"/>

</head>

<body class="gray-bg body_box">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">

        <form class="form-horizontal m-t js-ajax-forms" id="signupForm" action="{:U('Admin/My/resetPassword')}" method="post" enctype="multipart/form-data">
            <div class="col-sm-8 col-md-offset-2">

                <div class="ibox float-e-margins">

                    <div class="ibox-content">

                        <input name="ID" class="form-control" type="hidden" value="{$User.ID}">

                        <div class="form-group">
                            <label class="col-sm-3 control-label" for="Password">密码 *</label>
                            <div class="col-sm-8">
                                <input id="Password" name="Password" class="form-control" type="password" maxlength="16">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label" for="ConfirmPassword">确认密码 *</label>
                            <div class="col-sm-8">
                                <input id="ConfirmPassword" name="ConfirmPassword" class="form-control" type="password"  maxlength="16">
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 请再次输入您的密码</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button class="btn btn-primary keep" type="submit">保存</button>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<script src="__ROOT__/Public/Admin/js/jquery.min.js?v=2.1.4"></script>
<script src="__ROOT__/Public/Admin/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__ROOT__/Public/Admin/js/plugins/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript" src="__ROOT__/Public/Admin/js/ajaxForm.js"></script>
<script src="__ROOT__/Public/Admin/js/plugins/validate/jquery.validate.min.js"></script>
<script src="__ROOT__/Public/Admin/js/plugins/validate/messages_zh.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $.validator.setDefaults({
            highlight: function (element) {
                $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
            },
            success: function (element) {
                element.closest('.form-group').removeClass('has-error').addClass('has-success');
            },
            errorElement: "span",
            errorPlacement: function (error, element) {
                if (element.is(":radio") || element.is(":checkbox")) {
                    error.appendTo(element.parent().parent().parent());
                } else {
                    error.appendTo(element.parent());
                }
            },
            errorClass: "help-block m-b-none",
            validClass: "help-block m-b-none"
        });

        var icon = "<i class='fa fa-times-circle'></i> ";
        var form = $('form.js-ajax-forms');
        var formloading = false;
        //表单验证开始
        form.validate({
            //验证规则
            rules: {
                Password: {
                    required: true,
                    minlength: 5
                },
                ConfirmPassword: {
                    required: true,
                    minlength: 5,
                    equalTo: "#Password"
                }
            },
            //验证未通过提示消息
            messages: {
                Password:{
                    required: icon + "请输入密码",
                    minlength: icon + "密码必须5个字符以上"
                },
                ConfirmPassword: {
                    required: icon + "请再次输入密码",
                    minlength: icon + "密码必须5个字符以上",
                    equalTo: icon + "两次输入的密码不一致"
                }
            },
            //验证通过，提交表单
            submitHandler : function(forms) {
                if (formloading)
                    return;
                $(forms).ajaxSubmit({
                    url : form.attr('action'), //按钮上是否自定义提交地址(多按钮情况)
                    dataType : 'json',
                    beforeSubmit : function(arr, $form, options) {
                        formloading = true;
                    },
                    success : function(data, statusText, xhr, $form) {
                        formloading = false;
                        if (data.status) {
                            //添加成功
                            swal({
                                        title: "成功",
                                        text: "修改成功！",
                                        type: "success"
                                    },
                                    function (isConfirm) {
                                        swal.close();
                                    });

                        } else {
                            swal("操作失败", data.info, "error");
                        }
                    }
                });
            }
        });
    });
</script>
</body>
</html>